package com.ruoyi.apartments.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.apartments.domain.MfApartments;
import com.ruoyi.apartments.service.IMfApartmentsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 公寓房源信息Controller
 * 
 * @author ruoyi
 * @date 2025-07-21
 */
@RestController
@RequestMapping("/apartments")
public class MfApartmentsController extends BaseController
{
    @Autowired
    private IMfApartmentsService mfApartmentsService;

    /**
     * 查询公寓房源信息列表
     */
    @RequiresPermissions("apartments:apartments:list")
    @GetMapping("/list")
    public TableDataInfo list(MfApartments mfApartments)
    {
        startPage();
        List<MfApartments> list = mfApartmentsService.selectMfApartmentsList(mfApartments);
        return getDataTable(list);
    }


    /**
     * 导出公寓房源信息列表
     */
    @RequiresPermissions("apartments:apartments:export")
    @Log(title = "公寓房源信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MfApartments mfApartments)
    {
        List<MfApartments> list = mfApartmentsService.selectMfApartmentsList(mfApartments);
        ExcelUtil<MfApartments> util = new ExcelUtil<MfApartments>(MfApartments.class);
        util.exportExcel(response, list, "公寓房源信息数据");
    }

    /**
     * 获取公寓房源信息详细信息
     */
    @RequiresPermissions("apartments:apartments:query")
    @GetMapping(value = "/{apartmentId}")
    public AjaxResult getInfo(@PathVariable("apartmentId") Long apartmentId)
    {
        return success(mfApartmentsService.selectMfApartmentsByApartmentId(apartmentId));
    }

    /**
     * 新增公寓房源信息
     */
    @RequiresPermissions("apartments:apartments:add")
    @Log(title = "公寓房源信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MfApartments mfApartments)
    {
        return toAjax(mfApartmentsService.insertMfApartments(mfApartments));
    }

    /**
     * 修改公寓房源信息
     */
    @RequiresPermissions("apartments:apartments:edit")
    @Log(title = "公寓房源信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MfApartments mfApartments)
    {
        return toAjax(mfApartmentsService.updateMfApartments(mfApartments));
    }

    /**
     * 删除公寓房源信息
     */
    @RequiresPermissions("apartments:apartments:remove")
    @Log(title = "公寓房源信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{apartmentIds}")
    public AjaxResult remove(@PathVariable Long[] apartmentIds)
    {
        return toAjax(mfApartmentsService.deleteMfApartmentsByApartmentIds(apartmentIds));
    }
}
